<?php
namespace frontend\widgets;

use yii\bootstrap\Widget;
use yii\behaviors\CacheableWidgetBehavior;

class RenovationObjectProgress extends Widget
{
    public $title;
    public $statusStep;
    public $image;

    private $progressNames = [
        'Разработка концепции',
        'Разработка рабочего проекта',
        'Реализация',
        'Объект готов',
    ];

    private $cssDone = 'renobject-progress__done';
    private $cssInprogress = 'renobject-progress__inprogress';
    private $cssIdle = 'renobject-progress__idle';
    

    public function behaviors()
    {
        return [
            [
                'class' => CacheableWidgetBehavior::className(),
                'cacheDuration' => 3600,
            ],
        ];
    }
    
    public function init()
    {
        parent::init();

    }

    public function run()
    {   
        echo '<div class="container renovation-object renovation-object--inpage">
                <div class="row">
                    <div class="col-sm-12">
                        <div class="renovation-object__header">
                            <div>
                                <p>Реновация</p>
                                <h3 class="renovation-object__title">' . $this->title . '</h3>
                            </div>
                        </div>
                        <div class="renovation-object__image"><img src="' . $this->image . '"></div>
                    </div>
                </div>
            </div>';
        echo '<div class="container renobject-progress">
                <div class="row">';
        for ($iProgress=0; $iProgress < count($this->progressNames); $iProgress++) 
        { 
            if($iProgress < $this->statusStep-1)
            {
                echo '<div class="col-sm-3 renobject-progress__section ' . $this->cssDone . '">'
                        . $this->progressNames[$iProgress]
                    .'</div>';
            }
            if($iProgress == $this->statusStep-1)
            {
                echo '<div class="col-sm-3 renobject-progress__section ' . $this->cssInprogress . '">'
                        . $this->progressNames[$iProgress]
                    .'</div>';
            }
            if($iProgress > $this->statusStep-1)
            {
                echo '<div class="col-sm-3 renobject-progress__section ' . $this->cssIdle . '">'
                        . $this->progressNames[$iProgress]
                    .'</div>';
            }
        }
        echo '</div>
            </div>';      
    }

}
